/*
 * Copyright (c) 2009. Silenus Consultoria, S.L.
 */
package es.silenus.detecta.model;

/**
 * Survey lifecycle definition. This is a read-only persistent class.
 *
 * @author <a href="mailto:malonso@silenus-consultoria.es">Mariano Alonso</a>
 * @since 22-mar-2009 11:04:04
 */
public enum SurveyLifecycle implements IntegerEnumeration, java.io.Serializable {
/**
   * When a survey is being designed and not yet ready for production.
   */
	DESIGN(1, "survey.design"), 
/**
   * When a survey has data recorded an has not expired yet.
   */
	PRODUCTION(2, "survey.production"), 
/**
   * When a survey has expired.
   */
	CLOSED(3, "survey.closed"), 
/**
   * When a survey has been archived, after it has been expired.
   */
	ARCHIVED(4, "survey.archived");
	/**
	 * The identifier.
	 */
	private final int id;

	/**
	 * The key.
	 */
	private final String key;

/**
   * Constructor.
   *
   * @param id  the id.
   * @param key the key.
   */
	SurveyLifecycle(final int id, final String key) {
		this.id = id;
		this.key = key;
	}

	/**
	 * Retrieves the id.
	 *
	 * @return the id.
	 */
	public int getId() {
		return this.id;
	}

	/**
	 * Retrieves the key.
	 *
	 * @return the key.
	 */
	public String getKey() {
		return this.key;
	}

	/**
	 * Retrieves a value by its identifier.
	 *
	 * @param id the id.
	 *
	 * @return the origin.
	 */
	public static SurveyLifecycle getById(int id) {
		switch(id) {
			case 1:
				return DESIGN;

			case 2:
				return PRODUCTION;

			case 3:
				return CLOSED;

			case 4:
				return ARCHIVED;
		}

		return null;
	}
}
